/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2023. All rights reserved.
 * Description: Workflow 模式配置管理(后继考虑是不是集成他其他统一的配置模块)
 * Author: lilianlin
 * Create: 2019-11-28
 */

#include <mutex>
#include <array>
#include "workflow.h"
#include "adapter_rts.h"

static std::mutex g_workFlowModeMutex;

// workflowMode 调整成线程变量，避免全局变量被并行修改
static thread_local HcclWorkflowMode g_workflowMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;

static bool g_isLaunchKernel = false; // 是否为对接GE接口场景
static bool g_isTaskNumCal = false; // 是否为tasknum精确评估

HcclResult InitWorkflowMode(HcclWorkflowMode mode)
{
    CHK_RET(SetWorkflowMode(mode));
    return HCCL_SUCCESS;
}

HcclResult SetWorkflowMode(HcclWorkflowMode mode)
{
    g_workflowMode = mode;
    return HCCL_SUCCESS;
}

HcclWorkflowMode GetWorkflowMode()
{
    return g_workflowMode;
}

void SetLaunchKernelMode(bool state)
{
    g_isLaunchKernel = state;
}

bool IsLaunchKernelMode(void)
{
    return g_isLaunchKernel;
}

void SetTaskNumCalMode(bool state)
{
    g_isTaskNumCal = state;
}

bool IsTaskNumCalMode(void)
{
    return g_isTaskNumCal;
}